#pragma once
#include "Common.h"

#define SYMBOL_DATA_SIZE 0x100
#define IDENTIFIER_NAME_MAX_LEN 0x100

enum SYMBOL_TYPE
{
	ST_VARIABLE,
	ST_FUNCTION,
	ST_LABEL
};

struct Symbol
{
	enum SYMBOL_TYPE type;
	char name[IDENTIFIER_NAME_MAX_LEN];
};

#define PSUB_SYMBOL(S, SUB) ((SUB*)(((char*)(S)) + sizeof(struct Symbol)))

static const UInt symbolSizes[] = 
{
	sizeof(void*), // ST_VARIABLE
	sizeof(void*), // ST_FUNCTION
	sizeof(UInt), // ST_LABEL
};

// Sub classes of Symbol

struct VariableSymbol
{
	// For intermediate code, NULL if variable does not exist
	struct Variable* variable;
};

struct FunctionSymbol
{
	struct Instruction* i;
};

struct LabelSymbol
{
	UInt instructionCount;
};


BOOL DoesIdentifierSymbolExist(char* ascii);
struct Symbol* FindIdentifierSymbol(char* ascii);
struct Symbol* AddVariableSymbol(char* ascii);

extern UInt8 symbolData[SYMBOL_DATA_SIZE];
extern struct Symbol* symbols;